package com.xudow.app.dynamicstate_old.module.message;

import android.view.ViewGroup;
import android.widget.TextView;

import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.utils.JTimeTransform;
import com.xudow.app.R;
import com.xudow.app.dynamicstate_old.domain.entity.PushMessage;

import java.text.SimpleDateFormat;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by ske on 2016/7/6.
 */
public class SystemMsgViewHolder extends BaseViewHolder<PushMessage> {
    @BindView(R.id.text_title)
    TextView textTitle;
    @BindView(R.id.text_content)
    TextView textContent;
    @BindView(R.id.text_time)
    TextView textTime;
    @BindView(R.id.tv_delete)
    TextView delete;

    public SystemMsgViewHolder(ViewGroup parent) {
        super(parent, R.layout.item_system_msg);
        ButterKnife.bind(this, itemView);
    }

    @Override
    public void setData(PushMessage data) {
        textTitle.setText(data.getSenderName());
        textContent.setText(data.getContent());
        textTime.setText(new SimpleDateFormat("MM-dd HH:mm").format(data.getSendTime()));
        delete.setOnClickListener(v -> deleteListener.onDelete(getAdapterPosition(), data.getId()));
    }

    public void setOnDeleteListener(OnDeleteListener deleteListener) {
        this.deleteListener = deleteListener;
    }

    OnDeleteListener deleteListener;

    public interface OnDeleteListener {
        void onDelete(int position, long pid);
    }
}
